package ursaminor.lazywork.platform.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import ursaminor.lazywork.common.core.BaseController;
import ursaminor.lazywork.platform.model.Account;

/**
 * Handles requests for the application home page.
 */
@Controller
@RequestMapping("/index")
public class HomeController extends BaseController {
	
	@RequestMapping("")
	public ModelAndView index(HttpServletRequest req) {
		
		//检查account
		Account account = getCurrentAccount(req);
		if (account==null) {
			ModelAndView mav = new ModelAndView("internal");
			return mav;
		}
		
		//取得username、role
		ModelAndView mav = new ModelAndView("index");
		mav.addObject("username", account.getLoginName());
		mav.addObject("role", account.getRole());

		return mav;
	}
	
	@RequestMapping("/internal")
	public ModelAndView internal(HttpServletRequest req) {
		ModelAndView mav = new ModelAndView("internal");
		return mav;
	}
}
